package com.binarytree;

public class Solution15 {

    public int sumOfLeftLeaves(TreeNode root) {
        return getValue(root,0,0);
    }

    public int getValue(TreeNode root,int sum,int status) {
        if (root.left==null&&root.right==null&&status==0) {
            sum += root.val;
        }

        if (root.left!=null) {
            sum = getValue(root.left,sum,0);
        }

        if (root.right!=null) {
            sum = getValue(root.right,sum,1);
        }

        return sum;

    }
}
